﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SMIS.Dals;
using SMIS.Entities;

namespace SMIS
{
    public partial class ModifyDepart : Form
    {
        /// <summary>
        /// 【闻祖东 2013-4-8-194149】把这些参数统统去掉，用更加面向对象的方法来替代。
        /// </summary>
        public string MdfName { get; set; }
        public string MdfLeader { get; set; }
        public string MdfRemark { get; set; }
        public int MdfID { get; set; }

        public ModifyDepart()
        {
            InitializeComponent();
        }

        private void ModifyDepart_Load(object sender, EventArgs e)
        {
            txtName.Text = MdfName;
            txtLeader.Text = MdfLeader;
            txtRemark.Text = MdfRemark;
        }

        //【高月 2013-4-7-212709】确认修改部门信息的确认按钮事件
        private void button1_Click(object sender, EventArgs e)
        {
            Depart depart = new Depart();
            depart.Name = txtName.Text;
            depart.Leader = txtLeader.Text;
            depart.Remark = txtRemark.Text;
            depart.ID = MdfID;

            if (Dal4Depart.UpdateSelectedDepart(depart) == true)
            {
                if (MessageBox.Show("确定要修改部门信息？", "确认信息", MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Question) == DialogResult.OK)
                    MessageBox.Show("恭喜你修改部门信息成功！", "提示");
            }
            else
            {
                MessageBox.Show("部门名称发生重复", "提示");
            }
        }

        //取消
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
